﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using UnityEngine;

namespace Studio
{
	// Token: 0x02000512 RID: 1298
	public static class AssetBundleCheck
	{
		// Token: 0x170003E4 RID: 996
		// (get) Token: 0x06002117 RID: 8471 RVA: 0x000CB708 File Offset: 0x000C9908
		public static bool IsSimulation
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06002118 RID: 8472 RVA: 0x000CB70C File Offset: 0x000C990C
		public static string[] FindAllAssetName(string assetBundleName, string _regex, bool _WithExtension = true, RegexOptions _options = RegexOptions.None)
		{
			_regex = _regex.ToLower();
			AssetBundle assetBundle = AssetBundle.LoadFromFile(AssetBundleManager.BaseDownloadingURL + assetBundleName);
			string[] result;
			if (_WithExtension)
			{
				IEnumerable<string> allAssetNames = assetBundle.GetAllAssetNames();
				if (AssetBundleCheck.callback0 == null)
				{
					AssetBundleCheck.callback0 = new Func<string, string>(Path.GetFileName);
				}
				result = (from v in allAssetNames.Select(AssetBundleCheck.callback0)
				where AssetBundleCheck.CheckRegex(v, _regex, _options)
				select v).ToArray<string>();
			}
			else
			{
				IEnumerable<string> allAssetNames2 = assetBundle.GetAllAssetNames();
				if (AssetBundleCheck.callback1 == null)
				{
					AssetBundleCheck.callback1 = new Func<string, string>(Path.GetFileNameWithoutExtension);
				}
				result = (from v in allAssetNames2.Select(AssetBundleCheck.callback1)
				where AssetBundleCheck.CheckRegex(v, _regex, _options)
				select v).ToArray<string>();
			}
			assetBundle.Unload(true);
			return result;
		}

		// Token: 0x06002119 RID: 8473 RVA: 0x000CB7E4 File Offset: 0x000C99E4
		private static bool CheckRegex(string _value, string _regex, RegexOptions _options)
		{
			Match match = Regex.Match(_value, _regex, _options);
			return match.Success;
		}

		// Token: 0x0600211A RID: 8474 RVA: 0x000CB800 File Offset: 0x000C9A00
		public static bool FindFile(string _assetBundleName, string _fineName, bool _WithExtension = false)
		{
			_fineName = _fineName.ToLower();
			AssetBundle assetBundle = AssetBundle.LoadFromFile(AssetBundleManager.BaseDownloadingURL + _assetBundleName);
			if (assetBundle == null)
			{
				return false;
			}
			bool result;
			if (_WithExtension)
			{
				IEnumerable<string> allAssetNames = assetBundle.GetAllAssetNames();
				if (AssetBundleCheck.callback2 == null)
				{
					AssetBundleCheck.callback2 = new Func<string, string>(Path.GetFileName);
				}
				result = (allAssetNames.Select(AssetBundleCheck.callback2).ToList<string>().FindIndex((string s) => s == _fineName) != -1);
			}
			else
			{
				IEnumerable<string> allAssetNames2 = assetBundle.GetAllAssetNames();
				if (AssetBundleCheck.callback3 == null)
				{
					AssetBundleCheck.callback3 = new Func<string, string>(Path.GetFileNameWithoutExtension);
				}
				result = (allAssetNames2.Select(AssetBundleCheck.callback3).ToList<string>().FindIndex((string s) => s == _fineName) != -1);
			}
			assetBundle.Unload(true);
			return result;
		}

		// Token: 0x040022A2 RID: 8866
		[CompilerGenerated]
		private static Func<string, string> callback0;

		// Token: 0x040022A3 RID: 8867
		[CompilerGenerated]
		private static Func<string, string> callback1;

		// Token: 0x040022A4 RID: 8868
		[CompilerGenerated]
		private static Func<string, string> callback2;

		// Token: 0x040022A5 RID: 8869
		[CompilerGenerated]
		private static Func<string, string> callback3;
	}
}
